TreeTable({
	id:"menuTable",
	url:"/menu/page",
	data:[
	           {field: 'selectItem', radio: true},
	           {title: 'id', field: 'id',width:'5%'},
	           {title: '菜单名称', field: 'name'},
	           {title: '菜单编号', field: 'code'},
	           {title: '菜单父编号', field: 'pcode'},
	           {title: '权限名称', field: 'permission'},
	           {title: '请求地址', field: 'url'},
	           {title: '层级', field: 'levels',width:'5%'},
	           {title: '创建时间', field: 'createtime',},
	           {title: '状态', field: 'available',width:'5%',formatter:function(value,rows,index){
	        	   if(rows.available)
	        	   return '<button class="layui-btn layui-btn-mini layui-btn-normal table-list-status" data-id="'+rows.id+'" data-status="1">显示</button>';
	        	   else
	        		  return '<button class="layui-btn layui-btn-mini table-list-status layui-btn-warm" data-id="'+rows.id+'" data-status="0">隐藏</button>';
	           }},
	          ],
	 idField:"id",
	 codeField:"code",
	 parentCodeField:"pcode",
	 expandAll:true,
	 searchData:function(data){
		 console.log(data);
		 return data;
	 }
});
layui.use(['form', 'jquery', 'layer', 'dialog'], function() {
	var $ = layui.jquery;
	//修改状态
	$('#menuTable').on('click', '.table-list-status', function() {
		var That = $(this);
		var status = That.attr('data-status');
		var id = That.attr('data-id');
		if(status == 1) {
			status=0;
			That.removeClass('layui-btn-normal').addClass('layui-btn-warm').html('隐藏').attr('data-status', 0);
		} else if(status == 0) {
			status=1;
			That.removeClass('layui-btn-warm').addClass('layui-btn-normal').html('显示').attr('data-status', 1);
		}
		$.post("/menu/available",{id:id,available:status},function(data){
			if(data){
				status==1 && dialog.success("状态已更新为显示");
				status==0 && dialog.success("状态已更新为隐藏");
			}else{
				dialog.error("状态更新失败");
			}
		
		});
	})

});